<!DOCTYPE html>
<html lang="cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>保存部落战数据服务</title>
</head>

<body>

</body>
<script src="./js/forRange.js"></script>
<script src="./js/key.js"></script>
<script>
    var myDataName = '';
    var myDataName2 = '';
    var myDataName3 = '';
    var myDataName4 = '';
    time1 = setInterval(getData, 360000);
    time2 = setInterval(getData2, 370000);
    time3 = setInterval(getData3, 380000);
    time4 = setInterval(getData4, 390000);
    function getData() {
        $.ajax({
            url: allUrl + 'setWarData.php?tag=8CRUGCRU&name=Bigcatone&data=' + myDataName,
            type: 'GET',
            success: function (datas) {
                console.log('1成功');
                console.log(datas);
                if (datas == 'yes') {
                    clearInterval(time1);
                    setTimeout(startGetData, 86400000);
                    return;
                }
                var data = JSON.parse(datas);
                var opponentTag = data.opponent.tag;
                myDataName = changeTime(data.startTime);
            },
            error: function (e) {
                console.log(e.status, e.statusText);//状态码和信息
            },
            beforeSend: function () {
                console.log('1等待');
            }
        })
    }
    function startGetData() {
        time1 = setInterval(getData, 360000);
    }
    function getData2() {
        var xhr = $.ajax({
            url: allUrl + 'setWarData.php?tag=28YOOP9V2&name=Bigcattwo&data=' + myDataName2,
            type: 'GET',
            success: function (datas) {
                console.log('2成功');
                console.log(datas);
                if (datas == 'yes') {
                    clearInterval(time2);
                    setTimeout(startGetData2, 86400000);
                    return;
                }
                var data = JSON.parse(datas);
                var opponentTag = data.opponent.tag;
                myDataName2 = changeTime(data.startTime);
            },
            error: function (e) {
                console.log(e.status, e.statusText);//状态码和信息
            },
            beforeSend: function () {
                console.log('2等待');
            }
        })
    }
    function startGetData2() {
        time2 = setInterval(getData2, 370000);
    }
    function getData3() {
        var xhr = $.ajax({
            url: allUrl + 'setWarData.php?tag=28U9CQCQU&name=Bigcatthree&data=' + myDataName3,
            type: 'GET',
            success: function (datas) {
                console.log('3成功');
                console.log(datas);
                if (datas == 'yes') {
                    clearInterval(time3);
                    setTimeout(startGetData3, 86400000);
                    return;
                }
                var data = JSON.parse(datas);
                var opponentTag = data.opponent.tag;
                myDataName3 = changeTime(data.startTime);
            },
            error: function (e) {
                console.log(e.status, e.statusText);//状态码和信息
            },
            beforeSend: function () {
                console.log('3等待');
            }
        })
    }
    function startGetData3() {
        time3 = setInterval(getData3, 380000);
    }
    function getData4() {
        $.ajax({
            url: allUrl + 'setWarData.php?tag=289J0JRJV&name=Bigcatfour&data=' + myDataName4,
            type: 'GET',
            success: function (datas) {
                console.log('4成功');
                console.log(datas);
                if (datas == 'yes') {
                    clearInterval(time4);
                    setTimeout(startGetData4, 86400000);
                    return;
                }
                var data = JSON.parse(datas);
                var opponentTag = data.opponent.tag;
                myDataName4 = changeTime(data.startTime);
            },
            error: function (e) {
                console.log(e.status, e.statusText);//状态码和信息
            },
            beforeSend: function () {
                console.log('4等待');
            }
        })
    }
    function startGetData4() {
        time4 = setInterval(getData4, 390000);
    }

    function changeTime(time) {
        var str = time;
        var year = str.slice(0, 4);
        var mon = str.slice(4, 6);
        var data = str.slice(6, 8);
        return year + mon + data;
    }
</script>

</html>